package com.example.springbootdemo.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 *  minio配置类
 * </p>
 *
 * @author yurenwei
 * @since 2023/9/22
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {

    /**
     * 访问地址
     */
    private String endpoint;

    /**
     * 账户
     */
    private String accessKey;

    /**
     * 秘钥
     */
    private String secretKey;

    /**
     * 桶
     */
    private String bucket;

    /**
     * 创建MinioClient客户端
     *
     * @return
     */
    @Bean
    public MinioClient getMinioClient()  {
        return MinioClient.builder()
                .endpoint(getEndpoint())
                .credentials(getAccessKey(),getSecretKey())
                .build();
    }

}
